package com.mingqijia.gassafety.shared.constant;

import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.springframework.util.CollectionUtils;

import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

/**
 * 业务通知参数
 * @author guoliang.lao
 * @version v1.0.0
 * @date 2022年04月28日
 */
@Getter
@RequiredArgsConstructor
public enum BusinessNoticeParam {

    CM_SERVICE_HOT_LINE("燃气公司服务热线","cm_service_hot_line","燃气公司服务热线"),
    WX_ALERT_NOTICE("设备报警提醒（微信）","wx_alert_notice","设备报警时，进行微信推送提醒，开启推送填写“ON”，关闭推送填写“OFF”"),
    WX_ALERT_RECOVERY_NOTICE("设备报警恢复提醒（微信）","wx_alert_recovery_notice","设备报警状态恢复时，进行微信推送提醒，开启推送填写“ON”，关闭推送填写“OFF”"),
    WX_BROKEN_NOTICE("设备故障提醒（微信）","wx_broken_notice","设备故障时，进行微信推送提醒，开启推送填写“ON”，关闭推送填写“OFF”"),
    WX_BROKEN_RECOVERY_NOTICE("设备故障恢复提醒（微信）","wx_broken_recovery_notice","设备故障状态恢复时，进行微信推送提醒，开启推送填写“ON”，关闭推送填写“OFF”"),
    WX_OFFLINE_NOTICE("设备离线通知（微信）","wx_offline_notice","设备离线时，进行微信推送提醒，开启推送填写“ON”，关闭推送填写“OFF”"),
    WX_ONLINE_NOTICE("设备上线通知（微信）","wx_online_notice","设备上线时，进行微信推送提醒，开启推送填写“ON”，关闭推送填写“OFF”"),
    SYSTEM_ALERT_NOTICE("设备报警提醒（系统通知）","system_alert_notice","设备报警时，进行本地消息提醒，开启推送填写“ON”，关闭推送填写“OFF”"),
    SYSTEM_ALERT_RECOVERY_NOTICE("设备报警恢复提醒（系统通知）","system_alert_recovery_notice","设备报警状态恢复时，进行本地消息提醒，开启推送填写“ON”，关闭推送填写“OFF”"),
    SYSTEM_BROKEN_NOTICE("设备故障提醒（系统通知）","system_broken_notice","设备故障时，进行本地消息提醒，开启推送填写“ON”，关闭推送填写“OFF”"),
    SYSTEM_BROKEN_RECOVERY_NOTICE("设备故障恢复提醒（系统通知）","system_broken_recovery_notice","设备故障状态恢复时，进行本地消息提醒，开启推送填写“ON”，关闭推送填写“OFF”"),
    SYSTEM_OFFLINE_NOTICE("设备离线通知（系统通知）","system_offline_notice","设备离线时，进行本地消息提醒，开启推送填写“ON”，关闭推送填写“OFF”"),
    SYSTEM_ONLINE_NOTICE("设备上线通知（系统通知）","system_online_notice","设备上线时，进行本地消息提醒，开启推送填写“ON”，关闭推送填写“OFF”"),
    POP_ALERT_NOTICE("设备报警提醒（页面弹窗提醒）","pop_alert_notice","设备报警时，进行本地消息提醒，开启推送填写“ON”，关闭推送填写“OFF”"),
    POP_ALERT_RECOVERY_NOTICE("设备报警恢复提醒（页面弹窗提醒）","pop_alert_recovery_notice","设备报警状态恢复时，进行本地消息提醒，开启推送填写“ON”，关闭推送填写“OFF”"),
    POP_BROKEN_NOTICE("设备故障提醒（页面弹窗提醒）","pop_broken_notice","设备故障时，进行本地消息提醒，开启推送填写“ON”，关闭推送填写“OFF”"),
    POP_BROKEN_RECOVERY_NOTICE("设备故障恢复提醒（页面弹窗提醒）","pop_broken_recovery_notice","设备故障状态恢复时，进行本地消息提醒，开启推送填写“ON”，关闭推送填写“OFF”"),
    POP_OFFLINE_NOTICE("设备离线通知（页面弹窗提醒）","pop_offline_notice","设备离线时，进行本地消息提醒，开启推送填写“ON”，关闭推送填写“OFF”"),
    POP_ONLINE_NOTICE("设备上线通知（页面弹窗提醒）","pop_online_notice","设备上线时，进行本地消息提醒，开启推送填写“ON”，关闭推送填写“OFF”"),
    COCKPIT_TITLE("驾驶舱Title","cockpit_title","请填写1-14位汉字、字母、数字”"),
    COCKPIT_WARNING_INFO("驾驶舱告警信息展示控制","cockpit_warning_info","OFF:固定, ON滚动"),
    COCKPIT_CONTROL_ORDER("驾驶舱工单权限控制","cockpit_control_order","驾驶舱工单权限控制，ON开启展示 OFF不展示不配置默认不展示"),
    ALERT_STRATEGY_CHECK("报警策略审核（是否开启审核）","alert_strategy_check","操作报警策略时，开启策略审核填写“ON”，关闭策略审核填写“OFF”"),
    COCKPIT_WARN_STRATEGY_HIDE("驾驶舱报警策略通知展示控制","cockpit_warnstrategy_hide","显示报警策略填写“ON”，隐藏报警策略填写“OFF”"),
    BROKEN_FIRST_TIME_MSG("设备故障首次提醒（短信）", "broken_first_time_msg", "设备故障短信推送，请填写“ON”或者“OFF”，ON开启展示 OFF不展示，不配置默认不展示"),
    BROKEN_FIRST_TIME_WECHAT("设备故障首次提醒（微信）", "broken_first_time_wechat", "设备首次故障微信推送，请填写“ON”或者“OFF”，ON开启展示 OFF不展示，不配置默认不展示"),
    SYSTEM_LOGIN_OUT_AFTER_2H("系统退出登录前2小时声音提示", "system_login_out_after_2h","系统退出登录前2小时声音持续提示，请填写“ON”或者“OFF”，ON开启展示 OFF不展示，不配置默认不展示"),
    SYSTEM_LOGIN_OUT_POPUP_WINDOW("系统退出登录前2小时弹窗提示", "system_login_out_popup_window","系统退出登录前2小时弹窗提示，请填写“ON”或者“OFF”，ON开启展示 OFF不展示，不配置默认不展示"),
    SYSTEM_LOGIN_IN("系统账号登录提示展示控制", "system_login_in","系统登录时间展示，请填写“ON”或者“OFF”，ON开启展示 OFF不展示，不配置默认不展示"),
    H5_SERVICE_STATE("H5页面服务状态展示", "h5_service_state","H5设备详情页面的服务状态展示，请填写“ON”或者“OFF”，ON开启展示 OFF不展示，不配置默认不展示"),
    H5_RUNNING_RECORD("H5页面设备运行报告展示", "h5_running_record","H5设备列表页面的设备运行报告展示，请填写“ON”或者“OFF”，ON开启展示 OFF不展示，不配置默认不展示"),
    DEVICE_OFFLINE_AUTOMATION("设备离线之通讯周期设置", "device_offline_automation","设备存在信号不好、信号中断、拔电未上报等情况，设置长时间未上报即系统自动判断为设备离线，离线原因为通信不成功"),
    SYSTEM_POP_PRESENTATION_FORMAT("系统弹窗呈现形式", "system_pop_presentation_format","方便客户手动控制是否需要弹窗，请选择自动关闭或者手动关闭，并配置相关的弹窗事件"),
    ALARM_WORKORDER_AUTO_CANCEL("报警信息自动办结（报警自动恢复）","alarm_workorder_auto_cancel","报警信息自动办结，开启后，设备上报报警自动恢复时，报警信息自动办结且状态改为已完成"),
    BROKEN_WORKORDER_AUTO_CANCEL("报警信息自动办结（故障自动恢复）","broken_workorder_auto_cancel","报警信息自动办结，开启后，设备上报故障自动恢复时，报警信息自动办结且状态改为已完成"),
    DIFFERENT_SERVICE_PACKAGE_MODE("为不同服务套餐客户提供不同的服务模式","different_service_package_mode","不同的服务模式，开启后，系统按照所配置的服务项提供服务"),
    SYSTEM_ALERT_POP_SETTINGS("系统未处理消息弹窗提醒","system_alert_pop_settings","可配置当报警记录和故障记录中存在未处理的信息，开启系统弹窗提醒，默认系统弹窗10秒自动关闭，支持修改自动关闭时间或者修改成手动关闭或者不提醒");

    private final String name;
    private final String code;
    private final String remark;

    public static BusinessNoticeParam parse(String code) {
        List<BusinessNoticeParam> filtered = Arrays.stream(BusinessNoticeParam.values())
                .filter(item -> Objects.equals(item.getCode(), code))
                .collect(Collectors.toList());
        return CollectionUtils.isEmpty( filtered ) ? null : filtered.get(0);
    }

}
